import 'package:flutter/material.dart';
import 'package:flutter_widget/custom/custom_appbar.dart';

// ignore: must_be_immutable
class GridviewPage extends StatelessWidget {
  String name;
  GridviewPage({Key? key, required this.name}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppbar(name, Theme.of(context).primaryColor),
      body: GridView(
        gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
          mainAxisSpacing: 10, //主轴间隔
          crossAxisSpacing: 10, // 纵轴间隔
          crossAxisCount: 4, //排列个数
        ),
        // ignore: prefer_const_literals_to_create_immutables
        scrollDirection: Axis.vertical, //主轴对其方向
        shrinkWrap: true, // 是否滚动
        children: [
          Container(color: Colors.red),
          Container(color: Colors.blue),
          Container(color: Colors.pink),
          Container(color: Colors.purple),
          Container(color: Colors.yellow),
          Container(color: Colors.orange),
          Container(color: Colors.green),
          Container(color: Colors.cyan),
          Container(color: Colors.grey),
          Container(color: Colors.blueAccent),
        ],
      ),
    );
  }
}
